// 导入封装的根路径
import request from '@/utils/request.js'
// 用户登录请求封装
export const getUserLoginApi = (data) => {
  return request({
    method: 'post',
    url: 'login',
    data
  })
}

// 用户列表数据
export const getUsersApi = (params) => {
  return request({
    method: 'get',
    url: 'users',
    params
  })
}

// 修改用户状态
export const getUsersAlterApi = (data) => {
  return request({
    method: 'put',
    url: `users/${data.uld}/state/${data.type}`
  })
}

// 添加用户
export const getAddUsersApi = (data) => {
  return request({
    method: 'post',
    url: 'users',
    data
  })
}

// 修改用户信息
export const getAmendUsersApi = (data) => {
  return request({
    method: 'put',
    url: `users/${data.id}`,
    data
  })
}

// 根据ID查询用户信息
export const getUsersIdApi = (id) => {
  return request({
    method: 'get',
    url: `users/${id}`
  })
}

// 根据ID删除用户信息
export const getDeleteUsersIdApi = (id) => {
  return request({
    method: 'delete',
    url: `users/${id}`
  })
}

// 获取角色信息
export const getRolesApi = (id) => {
  return request({
    method: 'get',
    url: 'roles'
  })
}

// 分配用户角色
export const getAssignRolesApi = (id, data) => {
  return request({
    method: 'put',
    url: `users/${id}/role`,
    data
  })
}
